[QEMU] Simpler workaround for guest writes to PCI config
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 30 Nov 2006 17:32:16 +0000 (17:32 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 30 Nov 2006 17:32:16 +0000 (17:32 +0000)
space that extend past byte 0xff.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/ioemu/hw/pci.c
tools/ioemu/vl.h

index cea81f7b7f43c0e1adc18df378dfd80a68caae2d..77737c8615262a872060d33923e7ef2dbd3f3889 100644 (file)
@@ -221,24 +221,17 @@ uint32_t pci_default_read_config(PCIDevice *d,
                                  uint32_t address, int len)
 {
     uint32_t val;
-
     switch(len) {
-    default:
-    case 4:
-       if (address <= 0xfc) {
-           val = le32_to_cpu(*(uint32_t *)(d->config + address));
-           break;
-       }
-       /* fall through */
-    case 2:
-        if (address <= 0xfe) {
-           val = le16_to_cpu(*(uint16_t *)(d->config + address));
-           break;
-       }
-       /* fall through */
     case 1:
         val = d->config[address];
         break;
+    case 2:
+        val = le16_to_cpu(*(uint16_t *)(d->config + address));
+        break;
+    default:
+    case 4:
+        val = le32_to_cpu(*(uint32_t *)(d->config + address));
+        break;
     }
     return val;
 }
@@ -340,8 +333,7 @@ void pci_default_write_config(PCIDevice *d,
 
             d->config[addr] = val;
         }
-        if (++addr > 0xff)
-               break;
+        addr++;
         val >>= 8;
     }
 
index 4ff660c217797630573e6dcd99e63d88162bb9b6..3df963241c95d18d828c3a9f48f83211c08c4a30 100644 (file)
@@ -650,8 +650,11 @@ typedef struct PCIIORegion {
 #define PCI_MAX_LAT            0x3f    /* 8 bits */
 
 struct PCIDevice {
-    /* PCI config space */
-    uint8_t config[256];
+    /*
+     * PCI config space. The 4 extra bytes are a safety buffer for guest
+     * word/dword writes that can extend past byte 0xff.
+     */
+    uint8_t config[256+4];
 
     /* the following fields are read only */
     PCIBus *bus;